package Test29;

import java.time.Duration;
import java.time.LocalDateTime;

//Duration类的使用

public class Test15 {
    public static void main(String[] args) {

        //本地日期的时间对象
        LocalDateTime today = LocalDateTime.now();
        System.out.println(today);

        //出生的日期时间对象
        LocalDateTime birthday = LocalDateTime.of(2002, 1, 13, 12, 0, 0);
        System.out.println(birthday);

        Duration duration = Duration.between(birthday, today);
        System.out.println("相差的时间间隔对象：" + duration);

        System.out.println("----------------------------------");
        System.out.println(duration.toDays());//两个时间差的天数
        System.out.println(duration.toHours());//两个时间差的小时数
        System.out.println(duration.toMinutes());//两个时间差的分钟数
        System.out.println(duration.toMillis());//两个时间差的毫秒数
        System.out.println(duration.toNanos());//两个时间差的纳秒数
    }
}
